package com.example.testmodel;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

import com.github.ring.CircleProgress;

import java.util.concurrent.TimeUnit;

import io.reactivex.Observable;
import io.reactivex.functions.Consumer;

public class MainActivity extends AppCompatActivity {
    long aa = 0L;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        CircleProgress circleProgress = findViewById(R.id.circleprogress);
        circleProgress.setMaxProgress(6 * 1000);

//        Observable.interval(0, 300, TimeUnit.MILLISECONDS)
//                .take(30)
//                .map(new Function<Long, Long>() {
//                    @Override
//                    public Long apply(@NonNull Long aLong) throws Exception {
//                        return 30 - aLong;
//                    }
//                })
//                .compose(RxUtils.schedulers())
//                .as(RxUtils.bindLifecycle(this))
//                .subscribe(new Consumer<Long>() {
//                    @Override
//                    public void accept(Long aLong) throws Exception {
//                        System.out.println(aLong + "");
//                    }
//                });


        aa = System.currentTimeMillis();


        Observable.interval(0, 1, TimeUnit.MILLISECONDS)
                .compose(RxUtils.schedulers())
                .as(RxUtils.bindLifecycle(this))
                .subscribe(new Consumer<Long>() {
                    @Override
                    public void accept(Long aLong) throws Exception {
                        aa += 1000;
                        if ((aLong % 60 * 60) == 0) {
                            System.out.println(aa + "");
                        }
                    }
                });
    }
}